<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>MIS</title>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" type="text/css" href="../../lib/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../../stylesheets/theme.css">
<link rel="stylesheet" type="text/css" href="../../stylesheets/style.css">
<link rel="stylesheet" href="../../lib/font-awesome/css/font-awesome.css">
<script src="../../lib/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/bootstrap/js/bootstrap.js"></script>
<script src="../../lib/jquery.validate.min.js"></script>
<script src="../../lib/jquery.cookie.js"></script>
<script src="../../lib/jquery.messager.js"></script>
<script src="../../js/init.js"></script>

<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="lib/html5.js"></script>
<![endif]-->
</head>

<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->

<body class="">
	<!--<![endif]-->

	<div class="navbar"></div>
	<div class="common"></div>


	<div class="sidebar-nav"></div>

	<div class="content">
		<div class="well">
			<ul class="nav nav-tabs">
				<li class="active"><a href="#userlist" data-toggle="tab">企业列表</a></li>
			</ul>
			<div id="myTabContent" class="tab-content">
				<div class="tab-pane active in" id="userlist">
					<div class="btn-toolbar">
						<form class="form-inline ">
							<div class="row">
								<div class="input-prepend input-append span2">
									<span class="add-on">公司名称</span> 
									<input id="companyName" class="input-mini" type="text">
								</div>
								<div class="input-prepend input-append span2">
									<span class="add-on">账号</span>
									<input id="tel" class="input-mini" type="text">
								</div>
								<div class="input-prepend input-append span2">
									<button type="button" class="btn" id="searchbtn">查询</button>
									<button type="button" class="btn" id="addbtn">新建企业</button>
								</div>
							</div>
							<div class="row">
								<div class="input-prepend input-append span2">
									<span class="add-on">每页</span> <input id="list_page_size"
										class="input-mini" type="text" value="15"> <span
										class="add-on">条</span>
								</div>

								<div class="input-prepend input-append span2">
									<span class="add-on">第</span> <input id="list_page"
										class="input-mini" type="text" value="1"> <span
										class="add-on">页</span>
								</div>


								<div class="span2 input-append btn-group">
									<button type="button" class="btn" id="btn_jump">跳转</button>
									<button type="button" class="btn" id="btn_prev">上一页</button>
									<button type="button" class="btn" id="btn_next">下一页</button>
								</div>

							</div>
						</form>
					</div>

					<div class="control-group">
						<label class="control-label">总数</label> <label id="total"></label>
						<input class=" hidden" id="user_id">
					</div>
					<div class="well" id="loadimgdiv">
						<table class="table">
							<thead>
								<tr>
									<th>ID</th>
									<th>企业名称</th>
									<th>所在领域</th>
									<th width="250px">公司地址</th>
									<th>电子邮箱</th>
									<th>联系电话</th>
									<th>自加</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody id="user_tabel">

							</tbody>
						</table>
					</div>
					
					
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
	

		$(function() {
			initAdminNavBar();
			initCommon();
			initSideBar('user-management', 'company-list');
			$("#list_page_size").html(15);
			$("#list_page").html(1);
			reloadtable();

			$('#btn_jump').on('click', function(e) {
				reloadtable();
			});

			$('#btn_next').on('click', function(e) {
				var curpage = $('#list_page').val();
				$('#list_page').val(parseInt(curpage) + 1);
				reloadtable();
			});

			$('#btn_prev').on('click', function(e) {
				var curpage = $('#list_page').val();
				if (parseInt(curpage) > 1) {
					$('#list_page').val(parseInt(curpage) - 1);
					reloadtable();
				}
			});
			
			$('#searchbtn').on('click', function(e) {
				reloadtable();
			});
			$('#addbtn').on('click', function(e) {
				window.location.href="../usermanagement/editCompany.html";
			});
			

		});
		

		



		function reloadtable() {
			var companyName = $('#companyName').val();
			var tel = $('#tel').val();
			var pageSize = $('#list_page_size').val();
			var curPage = $('#list_page').val();
			$.ajax({
						contentType : "application/json",
						url : api_base_url + "selectCompany.json?"
								+ "pageSize=" + pageSize + "&curPage="
								+ curPage + "&companyName="
								+ companyName + "&tel="
								+ tel,
						dataType : "json",
						type : "get",
						success : function(data) {
							//alert(data);
							if (data.code == "200") {
								$('#list_page').html(pageSize)
								//refresh grid
								var rows = '';

								for (var int = 0; int < data.responseData.length; int++) {
									rows += "<tr>";
									rows += "<td>"
											+ data.responseData[int].companyId
											+ "</td>";
									rows += "<td>"
											+ data.responseData[int].companyName
											+ "</td>";
									rows += "<td>"
											+ data.responseData[int].dicFieldName
											+ "</td>";
									rows += "<td>"
											+ data.responseData[int].district + " " + data.responseData[int].location
											+ "</td>";
									rows += "<td>"
											+ data.responseData[int].email
											+ "</td>";
									rows += "<td>"
											+ data.responseData[int].tel
											+ "</td>";
									rows += "<td>"
											+ data.responseData[int].status
											+ "</td>";
									rows += "<td><a href='../usermanagement/companyDetail.html?companyId="
											+ data.responseData[int].companyId
											+ "' class='btn btn-success'>详情</a>";
									rows += "<a href='../usermanagement/internshiplist.html?companyId="
											+ data.responseData[int].companyId
											+ "' class='btn btn-success'>实习</a>";
									rows += "<a href='../usermanagement/parttimelist.html?companyId="
											+ data.responseData[int].companyId
											+ "' class='btn btn-success'>兼职</a>";
									rows += "<a href='../usermanagement/editCompany.html?companyId="
											+ data.responseData[int].companyId
											+ "' class='btn btn-success'>修改</a>";
									rows += "<a href='../usermanagement/editCompanyLogo.html?companyId="
											+ data.responseData[int].companyId
											+ "' class='btn btn-success'>图片</a>";
									rows += "<button  type='button' onclick='delCompany("
											+ data.responseData[int].companyId
											+ ")' class='btn btn-success'>删除</button>";
									rows += "</td>";
									rows += "</tr>";
								}

								$('#user_tabel').html(rows);
								$('#list_cur_page').text(curPage);
							}
							$.messager.anim('fade', 1000);
						    $.messager.show('操作提示',data.msg, 5000);
						}
					});
		}
		
		function delCompany(companyId) {
			$.ajax({
				contentType : "application/json",
				url : api_base_url + "delCompany.json?" + "companyId="
						+ companyId,
				dataType : "json",
				type : "get",
				success : function(data) {
					//alert(data);
					if (data.code == "200") {
						reloadtable();
					}
					$.messager.anim('fade', 1000);
				    $.messager.show('操作提示',data.msg, 5000);
				}
			});
		}
	</script>
</body>
</html>


